package com.itheima.health.controller;

import com.itheima.health.entity.Result;
import com.itheima.health.service.ReportService;
import com.itheima.health.vo.MemberReportVO;
import com.itheima.health.vo.ReportBussinessVO;
import com.itheima.health.vo.SetmealReportVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * 数据报告控制器
 */
@RestController
@RequestMapping("/report")
@Slf4j
@Api(tags = "数据报告展示接口")
public class ReportController {
    @Autowired
    private ReportService reportService;

    @GetMapping("/getMemberReport")
    @ApiOperation("获取近一年会员数")
    public Result getMemberReport(){
        MemberReportVO vo = reportService.getMemberReport();
        return Result.success(vo);
    }

    @GetMapping("/getSetmealReport")
    @ApiOperation("获取套餐统计信息")
    public Result getSetmealReport(){
        SetmealReportVo vo = reportService.getSetmealReport();
        return Result.success(vo);
    }

    @GetMapping("/getBusinessReportData")
    @ApiOperation("获取运营统计信息")
    public Result getBusinessReportData(){
        ReportBussinessVO vo = reportService.getBusinessReportData();
        return Result.success(vo);
    }

    @GetMapping("/exportBusinessReport")
    public void exportBusinessReport(HttpServletResponse response){
        reportService.exportBusinessReport(response);
    }

}
